package com.goodving.guli.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.TextView;

import com.goodving.guli.R;
import com.goodving.guli.bt.C0668a;
import com.goodving.guli.bt.C0708b;
import com.goodving.guli.bt.C0715c;
import com.goodving.guli.model.DeviceSource;
import com.goodving.guli.utility.Constants;
import com.goodving.guli.view.C3247b;

/**
 * Created by john on 2015/12/4.
 */
public class SelectDevicesActivity extends SystemBarTintActivity implements View.OnClickListener {
    private static final boolean f9229a = true;
    private static final int f9230b = 0;
    private static final int f9231c = 1;
    private static final long f9232d = 600;
    private View f9233e;
    private View f9234f;
    private View f9235g;
    private View f9236h;
    private TextView f9237i;
    private TextView f9238j;
    private AlphaAnimation f9239k;
    private AnimationSet f9240l;
    private RotateAnimation f9241m;
    private AnimationSet f9242n;

    private void m14063a() {
        this.f9240l = new AnimationSet(f9229a);
        this.f9242n = new AnimationSet(f9229a);
        Animation translateAnimation = new TranslateAnimation(0.0f, 0.0f, 0.0f, (float) getResources().getDimensionPixelSize(R.dimen.band_translate_y));
        translateAnimation.setDuration(f9232d);
        Animation scaleAnimation = new ScaleAnimation(1.0f, 1.54f, 1.0f, 1.54f, f9231c, 0.5f, 2, 0.0f);
        this.f9241m = new RotateAnimation(0.0f, 90.0f, f9231c, 0.5f, f9231c, 0.5f);
        this.f9241m.setDuration(f9232d);
        this.f9241m.setFillAfter(f9229a);
        this.f9240l.addAnimation(scaleAnimation);
        this.f9240l.addAnimation(translateAnimation);
        this.f9240l.setDuration(f9232d);
        this.f9240l.setFillAfter(f9229a);
        translateAnimation = new TranslateAnimation(0.0f, 0.0f, 0.0f, (float) (-getResources().getDimensionPixelSize(R.dimen.weight_trans_y)));
        scaleAnimation = new ScaleAnimation(1.0f, 1.378f, 1.0f, 1.378f, f9231c, 0.5f, 2, 0.0f);
        Animation alphaAnimation = new AlphaAnimation(1.0f, 0.7f);
        this.f9242n.addAnimation(scaleAnimation);
        this.f9242n.addAnimation(translateAnimation);
        this.f9242n.addAnimation(alphaAnimation);
        this.f9242n.setDuration(f9232d);
        this.f9242n.setFillAfter(f9229a);
        this.f9239k = new AlphaAnimation(1.0f, 0.0f);
        this.f9239k.setDuration(f9232d);
        this.f9239k.setFillAfter(f9229a);
    }

    private void m14064b() {
        this.f9236h = findViewById(R.id.select_devices_band_area);
        this.f9235g = findViewById(R.id.select_devices_scale_area);
        this.f9233e = findViewById(R.id.select_devices_band_icon);
        this.f9234f = findViewById(R.id.select_devices_scale_icon);
        this.f9237i = (TextView) findViewById(R.id.select_devices_band_txt);
        this.f9238j = (TextView) findViewById(R.id.select_devices_scale_txt);
        this.f9233e.setOnClickListener(this);
        this.f9234f.setOnClickListener(this);
        findViewById(R.id.select_devices_exit).setOnClickListener(this);
    }

    protected void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if ((i == 0 || i == f9231c) && i2 == -1) {
            finish();
        }
    }


    class dB implements Runnable {
        final /* synthetic */ SelectDevicesActivity f9849a;

        dB(SelectDevicesActivity selectDevicesActivity) {
            this.f9849a = selectDevicesActivity;
        }

        public void run() {
            this.f9849a.startActivityForResult(new Intent(this.f9849a, SearchSingleBraceletActivity.class), 0);
            this.f9849a.overridePendingTransition(R.anim.fw_in, R.anim.fw_out);
            this.f9849a.finish();
        }
    }

    class dC implements Runnable {
        final /* synthetic */ SelectDevicesActivity f9850a;

        dC(SelectDevicesActivity selectDevicesActivity) {
            this.f9850a = selectDevicesActivity;
        }

        public void run() {
            this.f9850a.startActivityForResult(new Intent(this.f9850a, SearchWeightScaleActivity.class), 1);
            this.f9850a.overridePendingTransition(R.anim.fw_in, R.anim.fw_out);
            this.f9850a.finish();
        }
    }

    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.select_devices_band_icon:
                if (DeviceSource.hasBindBracelet()) {
                    C3247b.m22928a((Context) this, (int) R.string.bind_bracelet_ok, (int) f9231c).show();
                    finish();
                    return;
                }
                C0668a.m8126a((Context) this, C0708b.f3704S);
                this.f9237i.startAnimation(this.f9239k);
                this.f9235g.startAnimation(this.f9239k);
                this.f9233e.startAnimation(this.f9241m);
                this.f9236h.startAnimation(this.f9240l);
                this.f9233e.postDelayed(new dB(this), 550);
            case R.id.select_devices_scale_icon:
                if (DeviceSource.hasBindWeight()) {
                    C3247b.m22928a((Context) this, (int) R.string.bind_weight_ok, (int) f9231c).show();
                    finish();
                    return;
                }
                C0668a.m8126a((Context) this, C0708b.aj);
                this.f9238j.startAnimation(this.f9239k);
                this.f9236h.startAnimation(this.f9239k);
                this.f9235g.startAnimation(this.f9242n);
                this.f9238j.postDelayed(new dC(this), 550);
            case R.id.select_devices_exit:
                C0668a.m8129a((Context) this, C0708b.f3707V, C0715c.f3772n, Constants.VIA_TO_TYPE_QQ_DISCUSS_GROUP);
                C0668a.m8129a((Context) this, C0708b.an, C0715c.f3772n, Constants.VIA_TO_TYPE_QQ_DISCUSS_GROUP);
                finish();
            default:
        }
    }

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        Intent intent = new Intent(this, GuliHardwareSettingActivity.class);
        intent.putExtra(GuliHardwareSettingActivity.f9247a, f9229a);
        startActivity(intent);
        finish();
    }
}